if exists (select * 
            from dbo.sysobjects 
            where "Name"='STT_INCALL' ) 
declare @t varchar(512),@str varchar(512),@create varchar(512) 
 begin
    select @t = (select "name" 
                 from dbo.sysusers 
                 where uid = (select uid 
                              from dbo.sysobjects 
                              where "Name"='STT_INCALL')) 
    set @str = 'if exists (select * from '+@t+'.STT_INCALL) 
                begin
                  select * into STT_INCALL_old  from '+@t+'.STT_INCALL 
                end
                drop table '+@t+'.STT_INCALL' 
    exec (@str)
 end

CREATE TABLE STT_INCALL
( ID NUMERIC(9) PRIMARY KEY,
  ID_USER NUMERIC(9) NOT NULL,
  CALL_COUNTER NUMERIC (9) NOT NULL,
  DATE_FROM DATETIME NOT NULL,
  DATE_TO DATETIME NOT NULL)

 

go
 if exists (select * 
            from dbo.sysobjects 
            where "Name"='STT_TRF_POPULATION' )
 declare @t1 varchar(512),@str1 varchar(512)
 begin
    select @t1 = (select "name" 
                  from dbo.sysusers 
                  where uid = (select uid 
                               from dbo.sysobjects 
                               where "Name"='STT_TRF_POPULATION')) 
    set @str1 = 'if exists (select * from '+@t1+'.STT_TRF_POPULATION) 
                 begin
                   select * into STT_TRF_POPULATION_old  from '+@t1+'.STT_TRF_POPULATION 
                 end
                drop table '+@t1+'.STT_TRF_POPULATION' 
    exec (@str1)
 end 
create table STT_TRF_POPULATION 
(id numeric primary key ,
 TRF_ID numeric NOT NULL,
 MEMBER_ID numeric NOT NULL,
 DATA_FROM datetime NOT NULL,
 DATA_TO datetime NOT NULL)


 if exists (select * 
            from dbo.sysobjects 
            where "Name"='STT_PROFIT' )
 declare @t2 varchar(512),@str2 varchar(512)
  begin
    select @t2 = (select "name" 
                  from dbo.sysusers 
                  where uid = (select uid 
                               from dbo.sysobjects 
                               where "Name"='STT_PROFIT')) 
    set @str2 = 'if exists (select * from '+@t2+'.STT_PROFIT) 
                 begin
                    select * into STT_PROFIT_old  from '+@t2+'.STT_PROFIT 
                 end
                 drop table '+@t2+'.STT_PROFIT' 
    exec (@str2);
 end 

create table STT_PROFIT
(id numeric primary key ,
 USERS_ID numeric NOT NULL,
 MONEY_LOST numeric NOT NULL,
 DATA_FROM datetime NOT NULL,
 DATA_TO datetime NOT NULL)